package com.ysd.ziyuanshiyongtongji.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import com.ysd.ziyuanshiyongtongji.dao.IConsumeLogDao;
import com.ysd.ziyuanshiyongtongji.model.ConsumeLog;
import com.ysd.ziyuanshiyongtongji.service.IConsumeLogService;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

/**
 * ConsumeLogController
 */
@RestController
@RequestMapping(path = "/consumeLog",method=RequestMethod.POST)
public class ConsumeLogController {
    @Resource
    private IConsumeLogService consumeLogService;
    @Resource
    private IConsumeLogDao consumeLogDao;
     @ApiOperation(value = "查询所有")
     @GetMapping
     public Map findAll(){
         List<ConsumeLog> list =consumeLogDao.findAll();
         Map<String,Object> map=new HashMap<String,Object>();
         map.put("code", 0);
        map.put("count",100);
        map.put("data", list);
        return map;
     }
    @ApiOperation(value = "刷卡",notes = "刷卡")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "readRoomId",value = "资源室编号",required = true,paramType = "path")
    })
    @PutMapping("/{readRoomId}/{cardNo}/{inOrOut}")
    public ConsumeLog enter(@PathVariable Integer readRoomId,@PathVariable String cardNo,@PathVariable boolean inOrOut){
        return consumeLogService.swipingCard(readRoomId, cardNo, inOrOut);
    }
}